import React from 'react'
import styles from './Cart.css'
import Images from "../Images";
import _ from 'lodash';
import {dispatch} from 'redux'
import { routerRedux } from 'dva/router';
import {connect} from "dva";
class Cart extends React.Component {
  constructor(props) {
    super(props)
    this.state={
      tokill:'逛逛秒杀'
    }
  }
  callBack=()=>{
     return this.setState({
      tokill:'秒杀过了'
    })
  }


 someFn=()=>{

   this.props.dispatch(routerRedux.push({
     pathname:'/kill',
     callBack:this.callBack
   }))
 }
  render() {
    let cartImage = _.get(Images, 'cartImage')
    return (
      <div className={styles.container}>
        <div className={styles.main}>
          <img className={styles.cart_iocn} src={cartImage}/>
          <span className={styles.null_tip}>购物车是空的</span>
        </div>
        <div className={styles.bottom}>
          <div onClick={this.someFn} className={styles.go_kill}>{this.state.tokill}</div>
          <div className={styles.go_fllow}>看看关注</div>
        </div>
      </div>
    )
  }
  componentWillMount () {
    console.log('cart componentWillMount')
    // add event listeners (Flux Store, WebSocket, document, etc.)
  }

  componentDidMount () {
    console.log('cart componentDidMount')
    // React.getDOMNode()
  }

  componentWillUnmount () {
    console.log('cart componentWillUnmount')
    // remove event listeners (Flux Store, WebSocket, document, etc.)
  }
}
export default connect()(Cart)
